<template>
    <div class="mui-numbox" data-numbox-step='1' data-numbox-min='1'>
        <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
        <input class="mui-numbox-input" type="number" @change="getNum()" ref="numbox"/>
        <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
    </div>
</template>

<script>
import mui from '@/lib/mui/js/mui.min.js'
export default {
    props:["stock_quantity"],
    mounted(){
        mui(".mui-numbox").numbox()
    },
    methods:{
        getNum(){
            this.$emit('getNum',this.$refs.numbox.value)
        }
    },
    watch:{
        stock_quantity(newVal,oldVal){
             mui(".mui-numbox").numbox().setOption('max',this.stock_quantity)
        }
    }
}
</script>

<style lang="scss" scoped>

</style>
